﻿/*======================================================================
== Copyright : BlueCurve (c)
== Licence   : Gnu/GPL v2.x
== Author    : Teddy Albina
== Email     : bluecurveteam@gmail.com
== Web site  : http://www.codeplex.com/BlueCurve
========================================================================*/
using System;
using System.Runtime.InteropServices;

namespace BlueCurve.Common.Share
{
    /// <summary>
    /// The NETRESOURCE structure contains information about a network resource. The structure is returned during enumeration of network resources. NETRESOURCE is also specified when making or querying a network connection with calls to various Windows Networking functions.
    /// http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wnet/wnet/netresource_str.asp
    /// </summary>
    internal struct NETRESOURCE
    {
        #region Nested

        /// <summary>
        /// Scope of the enumeration.
        /// </summary>
        public enum Scope : uint
        {
            /// <summary>
            /// Enumerate currently connected resources. The dwUsage member cannot be specified.
            /// </summary>
            RESOURCE_CONNECTED = 0x00000001,

            /// <summary>
            /// Enumerate all resources on the network. The dwUsage member is specified.
            /// </summary>
            RESOURCE_GLOBALNET = 0x00000002,

            /// <summary>
            /// Enumerate remembered (persistent) connections. The dwUsage member cannot be specified.
            /// </summary>
            RESOURCE_REMEMBERED = 0x00000003
        }

        /// <summary>
        /// Set of bit flags identifying the type of resource.
        /// </summary>
        public enum Type : uint
        {
            /// <summary>
            /// All resources
            /// </summary>
            RESOURCETYPE_ANY = 0x00000000,

            /// <summary>
            /// Disk resources
            /// </summary>
            RESOURCETYPE_DISK = 0x00000001,

            /// <summary>
            /// Print resources
            /// </summary>
            RESOURCETYPE_PRINT = 0x00000002
        }

        /// <summary>
        /// Display options for the network object in a network browsing user interface.
        /// </summary>
        public enum DisplayType : uint
        {
            /// <summary>
            /// The object should be displayed as a domain.
            /// </summary>
            RESOURCEDISPLAYTYPE_GENERIC = 0x00000000,

            /// <summary>
            /// The object should be displayed as a server.
            /// </summary>
            RESOURCEDISPLAYTYPE_DOMAIN = 0x00000001,

            /// <summary>
            /// The object should be displayed as a share.
            /// </summary>
            RESOURCEDISPLAYTYPE_SERVER = 0x00000002,

            /// <summary>
            /// The method used to display the object does not matter.
            /// </summary>
            RESOURCEDISPLAYTYPE_SHARE = 0x00000003,
        }

        /// <summary>
        /// Set of bit flags describing how the resource can be used. 
        /// Note that this member can be specified only if the dwScope member is equal to RESOURCE_GLOBALNET.
        /// </summary>
        public enum Usage : uint
        {
            /// <summary>
            /// The resource is a connectable resource; the name pointed to by the lpRemoteName member can be passed to the WNetAddConnection function to make a network connection.
            /// </summary>
            RESOURCEUSAGE_CONNECTABLE = 0x00000001,

            /// <summary>
            /// The resource is a container resource; the name pointed to by the lpRemoteName member can be passed to the WNetOpenEnum function to enumerate the resources in the container.
            /// </summary>
            RESOURCEUSAGE_CONTAINER = 0x00000002
        }

        #endregion Nested

        /// <summary>
        /// Scope of the enumeration.
        /// </summary>
        public NETRESOURCE.Scope dwScope;

        /// <summary>
        /// Set of bit flags identifying the type of resource.
        /// </summary>
        public NETRESOURCE.Type dwType;

        /// <summary>
        /// Display options for the network object in a network browsing user interface.
        /// </summary>
        public NETRESOURCE.DisplayType dwDisplayType;

        /// <summary>
        /// Set of bit flags describing how the resource can be used. 
        /// Note that this member can be specified only if the dwScope member is equal to RESOURCE_GLOBALNET.
        /// </summary>
        public NETRESOURCE.Usage dwUsage;

        /// <summary>
        /// If the dwScope member is equal to RESOURCE_CONNECTED or RESOURCE_REMEMBERED, this member is a pointer to a null-terminated character string that specifies the name of a local device. This member is NULL if the connection does not use a device.
        /// </summary>
        public string lpLocalName;

        /// <summary>
        /// If the entry is a network resource, this member is a pointer to a null-terminated character string that specifies the remote network name. 
        /// If the entry is a current or persistent connection, lpRemoteName points to the network name associated with the name pointed to by the lpLocalName member.
        /// The string can be MAX_PATH characters in length, and it must follow the network provider's naming conventions.
        /// </summary>
        public string lpRemoteName;

        /// <summary>
        /// Pointer to a null-terminated string that contains a comment supplied by the network provider. 
        /// </summary>
        public string lpComment;

        /// <summary>
        /// Pointer to a null-terminated string that contains the name of the provider that owns the resource. This member can be NULL if the provider name is unknown. To retrieve the provider name, you can call the WNetGetProviderName function. 
        /// </summary>
        public string lpProvider;
    }
}
